-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting GlobalFilter to Jotai #2955
base: master
Are you sure you want to change the base?
Conversation
@@ -1,25 +0,0 @@ | |||
import * as actionTemplates from './actions'; | |||
import chromeReducer, { chromeInitialState } from '.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need any of this middleware logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the on
event which leverages the middlewards. It can be and should done via jotai. https://github.com/Hyperkid123/insights-chrome/blob/master/src/chrome/create-chrome.ts#L100.
It was already done for the APP_NAVIGATION
public event. You can follow similar approach.
@@ -37,15 +32,3 @@ const globalFilter = { | |||
[GLOBAL_FILTER_REMOVE]: onGlobalFilterRemove, | |||
[GLOBAL_FILTER_UPDATE]: onTagSelect, | |||
}; | |||
|
|||
export const chromeInitialState: ReduxState = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In create-chrome and other files, there are references to these states. I tried stubbing the state out as unknown and a few variations to make this pr smaller. Any recommendations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the types to the jotai atoms and reference it there. Most of the existing jotai atoms are just migrated redux state variables. You can check how its done there.
}), | ||
shallowEqual | ||
); | ||
const { count, total, tags, sid, workloads, isLoaded } = useGlobalFilterState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a hook for this, may be unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When consolidating state variables, just be careful you are properly memorizing the state output. To prevent extra re-renders.
I don't see an issue with using the jotai atoms directly.
This will touch a lot of the code base, so I have some questions.